<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>管理店铺</title>
    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" href="css/hall.css">
    <link rel="stylesheet" href="css/myStore.css">
</head>
<body>
<div class="nav">
    <span class="nav">管理店铺</span>

    <div data-spm="nav" class="op-container">
        <a id="manageProducts" class="item-button" href="#" style="display: flex; align-items: center;">
            <img src="image/store.svg" style="object-fit: contain; width: 24px; height: 24px; margin-right: 4px;">
            <div style="margin-right: 16px;">管理商品</div>
        </a>
        <a class="item-button user" href="#"   style="display: flex; align-items: center;">
            <img src="image/tx.jpg" style="object-fit: contain; width: 50px; height: 50px; margin-right: 10px; border-radius: 50%;">
            <div id="store-name" class= "store-name" style="margin-right: 16px; font-size: 20px">null</div>
        </a>
    </div>
    <div class="user-info user" id="user-info" style="display: none;">
        <div class="row" >
            <img src="image/tx.jpg" style="object-fit: contain; width: 50px; height: 50px; margin-right: 10px; border-radius: 50%;">
            <div class="store-name" id="storeName" style="margin-right: 16px; font-size: 20px">null</div>
        </div>
        <div class="row">
            <span>电话：</span>
            <div id="contact" style="margin-right: 16px; font-size: 20px">null</div>
        </div>
        <div class="row">
            <span>简介：</span>
            <div id="introduction" style="margin-right: 16px; font-size: 20px">null</div>
        </div>
            <a id="updateStore" class="row" href="updateStore.html" style="margin-right: 16px; font-size: 20px;">
                修改信息
            </a>
        </div>
    </div>

</div>



<div class="store-container">
    <div class="item-button" style="margin-bottom: 10px">
        <a style="margin-right: 16px; font-size: 20px; color: black; cursor: pointer;">待发货</a>
        <a style="margin-right: 16px; font-size: 20px; color: black; cursor: pointer;">运输中</a>
        <a style="margin-right: 16px; font-size: 20px; color: black; cursor: pointer;">已完成</a>
        <a style="margin-right: 16px; font-size: 20px; color: black; cursor: pointer;">退货中</a>
        <a style="margin-right: 16px; font-size: 20px; color: black; cursor: pointer;">已退款</a>
    </div>

    <div class="stores" id="stores">
        <a class="store" href="#">
            <img class="store-image" src="image/tx.jpg" >
            <div class="store-name" >这是订单</div>
            <div class="store-introduction">这里是订单信息</div>
        </a>
    </div>



</div>
<script src="js/jquery.min.js"></script>
<script src="js/store.js"></script>
<script>
    $(document).ready(function() {
        let queryString = location.search;
        // 创建 URLSearchParams 对象
        let urlParams = new URLSearchParams(queryString);
        let storeId = urlParams.get("storeId");
        let storeName = urlParams.get("storeName");
        //更新信息绑定功能页面url
        $('.store-name').text(storeName);
        $('#manageProducts').attr("href", 'myProduct.html' + location.search);
        $('#updateStore').attr("href", 'updateStore.html?storeId=' + storeId);

        //处理信息显示
        const $aTag = $('.user');
        const $userInfo = $('#user-info');
        let hideTimer;

        $aTag.on('mouseover', function () {
            clearTimeout(hideTimer);
            $userInfo.show();
        });

        $userInfo.on('mouseover', function () {
            clearTimeout(hideTimer);
        });

        $(document).on('mouseout', function (e) {
            const relatedTarget = $(e.relatedTarget);
            if (!relatedTarget.closest($aTag).length && !relatedTarget.closest($userInfo).length) {
                hideTimer = setTimeout(() => {
                    $userInfo.hide();
                }, 200);
            }
        });

        selectStoreById(storeId, showStore);
        //展示商店信息
        function showStore(store) {
            $('.store-name').text(store.storeName);
            $('#contact').text(store.contactInfo);
            $('#introduction').text(store.storeIntroduction);
        }
    });
</script>
</body>
</html>